<%@ include file="/common/taglibs.jsp"%>
<probiz:pageHeading pageHeadingKey="smsQueueList.heading" />

<content tag="buttons">
	<probiz:iconBtn btnType="add" onclick="return fnDoAdd(this);" />
	<probiz:iconBtn btnType="sms" btnTextKey="common.iconBtn.reSend" onclick="return reSendSms(this);" />
	<probiz:iconBtn btnType="delete" onclick="return fnDoMultiDelete(this);" />
</content>
<search:searchBox formAction="${ctxPath}/tool/smsQueue.html" enableMoreSearch="true">
	<div class="basic_search">
		<search:basicSearch attrPath="s.smsContent" attrNameKey="smsQueue.smsContent" datatype="String" operator="LIKE" classes="inputtxt" labelWidth="80px"/>
	</div>
	<div class="more_search">
		<table border="0" cellspacing="0" cellpadding="0" class="search_table">
			<tr>
				<th><fmt:message key="smsQueue.status"/>:</th>
				<td>
					<select name="COL@s.status@Short@EQ" id="COL@s.status@Short@EQ">
						<option value=""><fmt:message key="tool.sms.choice"/></option>
						<option value="0" ${(param['COL@s.status@Short@EQ']==0 && not empty param['COL@s.status@Short@EQ'])?'selected':'' }><fmt:message key="tool.sms.notSend"/></option>
						<option value="1" ${(param['COL@s.status@Short@EQ']==1 && not empty param['COL@s.status@Short@EQ'])?'selected':'' }><fmt:message key="tool.sms.sendsucceed"/></option>
					</select>
				</td>
			</tr>
		<search:input attrPath="s.phoneNumbers" attrNameKey="smsQueue.phoneNumbers" datatype="String" operator="LIKE" classes="inputtxt" labelWidth="80px"/>
		
		<tr>
			<c:set var="createTimeGTE">COL@s.createTime@Date_Begin@GTE</c:set>
			<c:set var="createTimeLTE">COL@s.createTime@Date_End@LTE</c:set>
			<th width="60px"><label for="${createTimeGTE}"><fmt:message key="orderShipment.createTime"/>:</label></th>
			<td>
				<span><input type="text" id="createTimeGTE" name="${createTimeGTE}" value="${sc==null?requestScope[createTimeGTE]:sc.param[createTimeGTE]}" style="width:61px"  class="inputtxt"  onblur="validateEventHandler();"/></span>
				<probiz:ui_datePicker outPut="createTimeGTE" />
				<fmt:message key ="orderPayment.search.to"/>
				<span><input type="text" id="createTimeLTE" name="${createTimeLTE}" value="${sc==null?requestScope[createTimeLTE]:sc.param[createTimeLTE]}" style="width:61px"  class="inputtxt"  onblur="validateEventHandler();"/></span>
				<probiz:ui_datePicker outPut="createTimeLTE" />
			</td>
		</tr>
		</table>
	</div>	
</search:searchBox>

<form class="mainForm" name="smsQueueListForm" id="smsQueueListForm" method="post">
	<input type="hidden" name="doAction" id="doAction" value=""/> 
	<!--editURLPath is used in TblDecorator-->
	<c:set var="editURLPath" value="/tool/smsQueue.html?doAction=edit&from=list" scope="page" />
	<div class="top clearfix">
		<ul class="tab">
			<li class="curr"><span><fmt:message key="smsQueueList.heading"/></span></li>
		</ul>
		<%@include file="/common/pagingOnlyTop.jsp"%>
	</div>
	<div class="data">
	<c:set var="checkAll"><input type="checkbox" name="allbox" onclick="checkAll(this.form)" class="checkbox"/></c:set>
	<display:table name="${smsQueueList}" cellspacing="0" cellpadding="0" uid="smsQueueItem" class="list_table" export="false" requestURI="" style="width:100%">
		<display:column class="checkbox_column" title="${checkAll}" media="html">
			<input type="checkbox" name="multiIds" value="${smsQueueItem.smsQueueId}" class="checkbox" title="${smsQueueItem.phoneNumbers}"/>
		</display:column>
		<display:column sortable="true" url="${editURLPath}" paramId="smsQueueId" paramProperty="smsQueueId"
			decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.smsContent">
			<common:displayString length="30" value="${smsQueueItem.smsContent}"/>
		</display:column>
	    <display:column style="width: 10%" sortable="true" headerClass="data-table-title"
    		decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.phoneNumbers">
			<common:displayString length="30" value="${smsQueueItem.phoneNumbers}"/>
    	</display:column>
    	<%--
    	<display:column property="customerNames" sortable="true" headerClass="data-table-title"
    		decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.customerNames"/>
    	 --%>
	    
	    <display:column style="width: 6%" sortable="true" headerClass="data-table-title"
    		decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.status">
    		<c:choose>
				<c:when test="${smsQueueItem.status eq 1 }"><fmt:message key="smsQueue.status1"/></c:when>
				<c:otherwise><fmt:message key="smsQueue.status0"/></c:otherwise>
			</c:choose>
    	</display:column>	
	    <display:column style="width: 6%" property="sendStatus" sortable="true" headerClass="data-table-title"
    		decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.sendStatus"/>
	    <display:column style="width: 8%" property="sendTime" sortable="true" headerClass="data-table-title"
    		decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.sendTime"/>
	    <display:column style="width: 8%" property="createTime" sortable="true" headerClass="data-table-title"
    		decorator="com.probiz.estore.core.decorator.TblColumnDecorator" titleKey="smsQueue.createTime"/>
	</display:table>
	<%@include file="/common/pagingOnly.jsp"%>
	</div>
</form>
<script type="text/javascript">
	highlightTableRows("smsQueueItem");
	
	function fnDoMultiDelete(obj, showItemNames/*true or false, default is true*/) {
		var itemNames = fnGetSelectedItemNames();
		if (itemNames=="") {
			jAlert(__FMT.common_multiDelete_pleaseSelect);
			return false;
		}
		if(showItemNames==null || showItemNames){
			var tit = itemNames.length>59?(itemNames.substring(0,59)+"..."):itemNames;
			return fnDoAction(obj, "multiDelete", __FMT.common_message_confirmDeleteThis+ " " + tit +"?"+"\n共"+itemNames.split(",").length+"条。");
		}else{
			return fnDoAction(obj, "multiDelete", __FMT.common_message_confirmDeleteThis + "?");
		}
	}
	
	function reSendSms(obj){
		var paraData=$j("#smsQueueListForm :input[name='multiIds']").serializeArray();
		if(paraData.length>0){
			var itemNames = fnGetSelectedItemNames();
				if(confirm("<fmt:message key='tool.sms.reSendTip'/>  "+ " " + itemNames+"?")){
				$("doAction").value="sendSms2List";
				$("smsQueueListForm").submit();
				//$j.post(__ctxPath + "/tool/smsQueue.html?doAction=sendSms2List", paraData, null);
			}
		}else{
			alert("<fmt:message key='tool.sms.dataChoice'/>");
		}
	}
	
	function reSendMsgCallback(data){
		window.location.href=__ctxPath + "/tool/smsQueue.html";
	}
</script>